extends Node2D

@export var game_is_start:bool = false;

@export var slime:PackedScene;
@export var spawn_timer:Timer;
@export var gameOverLabel:Label;

# 击杀积分
@export var score:int = 0;
@export var scoreLabel:Label;

# 逃掉的史莱姆
@export var getawaySlimeNum:int = 0;
@export var GetawaySlimeNumLabel:Label;

# 2s内连续击杀
@export var noStopKillNum:int = 0;
var isNoneStopKill:bool = false
@export var NotStopKillLabel:Label;

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	if game_is_start:
		$GameNotStarted/Button.visible = !game_is_start
		$GameStarted.visible = game_is_start
	spawn_timer.wait_time-=0.2 * delta
	spawn_timer.wait_time = clamp(spawn_timer.wait_time,1,3)
	scoreLabel.text = '消灭数量：'+str(score)
	GetawaySlimeNumLabel.text = '逃掉的史莱姆：'+str(getawaySlimeNum)
	if noStopKillNum == 0:
		NotStopKillLabel.text = ''
	else:
		if score == 1:
			NotStopKillLabel.text = '第一滴血'
		elif noStopKillNum == 2:
			NotStopKillLabel.text = '双杀'
		elif noStopKillNum == 3:
			NotStopKillLabel.text = '三杀'
		elif noStopKillNum == 4:
			NotStopKillLabel.text = '四杀'
		elif noStopKillNum == 5:
			NotStopKillLabel.text = '五连绝世'
		elif noStopKillNum > 5:
			NotStopKillLabel.text = '超神！！！'
		else:
			NotStopKillLabel.text = "KILL " + str(noStopKillNum)
func add_new_slime() -> void:
	if not get_tree().current_scene.game_is_start:
		return
	var slime_node = slime.instantiate()
	slime_node.position = Vector2(240,randf_range(50,100))
	get_tree().current_scene.add_child(slime_node)

func show_game_over() -> void:
		gameOverLabel.visible = true


func reset_kill_num() -> void:
	
	isNoneStopKill = false
	noStopKillNum = 0
		
